import App from '../views/app.vue'
// import store from '../store'
// import config from './config'

import lazyLoading from '../api/lazyLoading.js'
export const config = {
    routers: {
        items: [{
            name: 'pc',
            path: '/pc',
            meta: {
                title: 'PC页面',
                link: 'pc/index.vue'
            },
            component: lazyLoading('pc', true)
        }
        ]
    }
}

/**
 * 配置多入口页面 挂载组件等
 */
export default [{
    path: '/',
    component: App,
    children: [{
        path: '/', //首页
        name: '/',
        meta: { title: '首页' },
        component: lazyLoading('mobile', true)
    },
    ...generateRoutesFromMenu(config.routers.items),
    ]
}]

// Menu should have 2 levels.
function generateRoutesFromMenu(menu = [], routes = []) {
    for (let i = 0, l = menu.length; i < l; i++) {
        let item = menu[i]
        if (item.path) {
            routes.push(item)
        }
        if (!item.component) {
            generateRoutesFromMenu(item.children, routes)
        }
    }
    return routes
}